package org.example.everyday;

import java.util.ArrayList;
import java.util.List;

/**
 * https://leetcode-cn.com/problems/number-of-rectangles-that-can-form-the-largest-square/
 */
public class CountGoodRectangles {

    /**
     * rectangles = [[5,8],[3,9],[5,12],[16,5]]
     * @param rectangles
     * @return
     */
    public int countGoodRectangles(int[][] rectangles) {
        int res = 0,maxLen = 0;
        for(int[] rec:rectangles){
            int l = rec[0],w=rec[1];
            int k = Math.min(l,w);
            if(k == maxLen){
                res++;
            }else if(k > maxLen){
                res = 1;
                maxLen = k;
            }
        }
        return res;
    }

    public static void main(String[] args) {
        CountGoodRectangles c = new CountGoodRectangles();
//        int[][] array = new int[][]{{5,8},{3,9},{5,12},{16,5}};

        int[][] array = new int[][]{{2,3},{3,7},{4,3},{3,7}};
        int result = c.countGoodRectangles(array);
        System.out.println(result);
    }

}
